/**
 * 财务信息
 */

import { RosterInterface } from '@/api/interface/personnel/roster/roster';
import { BasicForm } from '@/components/ProForm/interface';

export function useFinancialInfoForm(getFinancialInfoData: Function) {
  let financialInfoForm = reactive<BasicForm<RosterInterface.ReqFinanceInfoSave>>({
    form: {
      bankName: '',
      bankNumber: '',
      socialSecurityNumber: '',
      commercialInsurance: '',
      accumulationFund: '',
      remark: '',
      rosterId: null
    },
    title: '',
    minWidth: 660,
    labelWidth: [100, 120],
    visible: false,
    formAttrs: {
      labelWidth: '140px'
    },
    options: [
      {
        type: 'input',
        label: 'ID',
        prop: 'rosterId',
        hide: true
      },
      {
        type: 'input',
        label: '主表id',
        prop: 'rosterId',
        hide: true
      },
      {
        type: 'input',
        hide: false,
        prop: 'bankName',
        label: '开户行'
        // rules: [
        //   {
        //     required: true,
        //     message: "开户行",
        //     trigger: "blur"
        //   }
        // ]
      },
      {
        type: 'input',
        hide: false,
        prop: 'bankNumber',
        label: '银行卡号'
        // rules: [
        //   {
        //     required: true,
        //     message: "银行卡号",
        //     trigger: "blur"
        //   }
        // ]
      },

      {
        type: 'input',
        hide: false,
        prop: 'socialSecurityNumber',
        label: '社保编号'
        // rules: [
        //   {
        //     required: true,
        //     message: "社保编号",
        //     trigger: "blur"
        //   }
        // ]
      },
      {
        type: 'input',
        hide: false,
        prop: 'commercialInsurance',
        label: '商保编号'
        // rules: [
        //   {
        //     required: true,
        //     message: "商保编号",
        //     trigger: "blur"
        //   }
        // ]
      },
      {
        type: 'input',
        hide: false,
        prop: 'accumulationFund',
        label: '公积金账号'
        // rules: [
        //   {
        //     required: true,
        //     message: "公积金账号",
        //     trigger: "blur"
        //   }
        // ]
      },
      {
        type: 'input',
        hide: false,
        prop: 'remark',
        label: 'remark',
        attrs: {
          style: {
            width: '500px'
          }
        }
      }
    ]
  });

  /**
   * 打开表单
   */
  const openFinancialInfoForm = (title: string, row?) => {
    formOpen(financialInfoForm, title, row);
  };

  /**
   * @description: 保存表单数据
   * @return {*}
   */
  const saveAddFinancialInfoForm = async form => {
    await financeInfoSave(form);
    financialInfoForm.visible = false;
    elMessage();
    getFinancialInfoData();
  };

  return { financialInfoForm, saveAddFinancialInfoForm, openFinancialInfoForm };
}
